package com.tang.usercenter.users.service.imp;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.tang.usercenter.common.util.ConstantFinalUtil;
import com.tang.usercenter.sapi.pojo.AAdmins;
import com.tang.usercenter.sapi.service.IUserService;
import com.tang.usercenter.users.dao.IAdminsDao;
@Service("userService")
public class UserServiceImp implements IUserService{

    @Resource
    private IAdminsDao adminsDao;
    /*===================管理员操作开始=====================*/
    @Override
    public AAdmins searchOneAdminsService(Map<String, Object> condMap) {
	
	return this.adminsDao.searchOne(condMap);
    }

    @Override
    public JSONObject insertOneAdminsService(AAdmins admins) {
	JSONObject resultJSON = new JSONObject();
	int res = this.adminsDao.insertOne(admins);
	if(res > 0 )
	{
		resultJSON.put("code", "0");
		resultJSON.put("info", ConstantFinalUtil.INFO_JSON.get("0"));
		
		/* 存储data */
		JSONObject dataJSON = new JSONObject();
		dataJSON.put("id", admins.getId() + "");
		dataJSON.put("effect", res + "");
		
		resultJSON.put("data", dataJSON);
	}else
	{
		resultJSON.put("code", "1");
		resultJSON.put("info", ConstantFinalUtil.INFO_JSON.get("1"));
	}
	return resultJSON;
    }

    @Override
    public JSONObject updateOneAdminsService(AAdmins admins) {
	JSONObject resultJSON = new JSONObject();
	/* 影响条数 */
	int res = this.adminsDao.updateOne(admins);
	/*String str = null ; 
	str.toString();*/
	if(res > 0 )
	{
		resultJSON.put("code", "0");
		resultJSON.put("info", "成功");
		
		/* 存储data */
		JSONObject dataJSON = new JSONObject();
		dataJSON.put("id", admins.getId() + "");
		dataJSON.put("effect", res + "");
		
		resultJSON.put("data", dataJSON);
	}else
	{
		resultJSON.put("code", "2");
		resultJSON.put("info", ConstantFinalUtil.INFO_JSON.get("2"));
	}
	return resultJSON;
    }

    @Override
    public JSONObject deleteOneAdminsService(AAdmins admins) {

	JSONObject resultJSON = new JSONObject();
	/* 影响条数 */
	int res = this.adminsDao.deleteOne(admins);
	/*String str = null ; 
	str.toString();*/
	if(res > 0 )
	{
		resultJSON.put("code", "0");
		resultJSON.put("info", "成功");
		
		/* 存储data */
		JSONObject dataJSON = new JSONObject();
		dataJSON.put("id", admins.getId() + "");
		dataJSON.put("effect", res + "");
		
		resultJSON.put("data", dataJSON);
	}else
	{
		resultJSON.put("code", "3");
		resultJSON.put("info", ConstantFinalUtil.INFO_JSON.get("3"));
	}
	return resultJSON;
    }

    @Override
    public void searchAdminsCondList(Map<String, Object> condMap) {
	// TODO Auto-generated method stub
	
    }
    /*===================管理员操作结束=====================*/
    
}
